export function getAuthorization() {


  if (!localStorage.getItem('Authorization')) {
    //返回首页登录
    return "";
  }
  return localStorage.getItem('Authorization');
}

export function saveAuthorization(access_token) {
  localStorage.removeItem('Authorization');
  localStorage.setItem('Authorization', access_token);
}


export function removeAuthorization() {
  localStorage.removeItem('menus');
  localStorage.removeItem('user');
  localStorage.removeItem('roles');
  localStorage.removeItem('org');
  localStorage.removeItem('Authorization');
}


export function saveUser(user) {
  return localStorage.setItem('user', JSON.stringify(user));
}

/**
 * "userinfo": {
			"userId": 99999,
			"userCode": "yym",
			"userName": "严月梅",
			"empNo": null,
			"password": null,
			"orgId": 1,
			"mobilePhone": null,
			"email": null,
			"userLevel": null,
			"remark": null,
			"userState": 0,
			"hisPwdOne": null,
			"hisPwdOtwo": null,
			"createTime": "2019-04-30T01:24:15.000+0000",
			"createUserCode": "",
			"updateTime": "2019-05-11T06:16:12.000+0000",
			"updateUserCode": null,
			"delFlag": 0,
			"sex": null,
			"bornDate": null,
			"nativePlace": null,
			"identityCard": null,
			"degree": null,
			"graduateSchool": null,
			"telphone": null,
			"fax": null,
			"profession": null,
			"jobPost": null,
			"position": null,
			"officeAddress": null,
			"companyName": null,
			"companyAddress": null,
			"homeAddress": null
		}
 * @returns {any}
 */
export function getUser() {
  return JSON.parse(localStorage.getItem('user'));
}

export function saveRoles(roles) {
  return localStorage.setItem('roles', JSON.stringify(roles));
}

/**
 *
 * "roles": [{
			"id": 1,
			"roleCode": "sysadmin",
			"roleName": "系统管理员",
			"isDefault": 0,
			"dataScope": 1,
			"roleState": 0,
			"createTime": "2019-04-24T02:15:41.000+0000",
			"remark": "系统管理员",
			"delFlag": 1
		}
 *
 *
 * @returns {any}
 */
export function getRoles() {
  return JSON.parse(localStorage.getItem('roles'));
}

/**
 *
 *
 *
 *
 *
 * **/
export function saveOrg(org) {
  return localStorage.setItem('org', JSON.stringify(org));
}

/**
 *  {
			"orgCode": "asdbcxcx001",
			"orgName": "BWDA",
			"orgAdminCode": null,
			"parentId": 0,
			"parentIds": "0",
			"parentNames": "",
			"remark": "BWDA",
			"delFlag": 0
		}
 * @returns {any}
 */
export function getOrg() {
  return JSON.parse(localStorage.getItem('org'));
}

export function saveMenus(menus) {
  return localStorage.setItem('menus', JSON.stringify(menus));
}

export function getMenus() {
  return JSON.parse(localStorage.getItem('menus'));
}

export function saveConfigs(configs) {
  return localStorage.setItem('configs', JSON.stringify(configs));
}

export function getConfigs() {
  return JSON.parse(localStorage.getItem('configs'));
}

/**
 * 要求兼容以前的，所以从不同的菜单进入页面，会展示不同的文件地址栏
 * @param from
 */
export function saveMenuFrom(from) {
  return localStorage.setItem('menuFrom', from);
}

export function getMenuFrom() {
  return localStorage.getItem('menuFrom');
}

/**
 * 不同文件配置的名称
 * @param configs
 */
export function saveFileCodeToName(configs) {
  return localStorage.setItem('fileCodeToName', JSON.stringify(configs));
}

/**
 * 不同文件配置的名称
 * @returns {any}
 */
export function getFileCodeToname() {
  return JSON.parse(localStorage.getItem('fileCodeToName'));
}
